package leetcode.秋招.顺丰;

import java.util.ArrayList;
import java.util.Scanner;

/**
 * @author ：zsy
 * @date ：Created 2021/8/30 19:48
 * @description：
 */
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s = in.nextLine();
        String[] strs = s.split(" ");
        int len = strs.length;
        int[] factor = new int[len];
        for (int i = 0; i < strs.length; i++) {
            factor[i] = Integer.parseInt(strs[i]);
        }
        int n = in.nextInt();
        int[] sums = new int[n];
        int max = 0;
        int[][] nums = new int[n][len];
        for (int i = 0; i < n; i++) {
            int sum = 0;
            for (int j = 0; j < len; j++) {
                nums[i][j] = in.nextInt() * factor[j];
                sum += nums[i][j];
            }
            max = Math.max(max, sum);
            sums[i] = sum;
        }
        int count = 0;
        ArrayList<Integer> list = new ArrayList<>();
        for (int i = 0; i < sums.length; i++) {
            if (sums[i] == max) {
                count++;
                list.add(i + 1);
            }
        }
        System.out.println(max);
        System.out.println(count);
        for (int i = 0; i < list.size(); i++) {
            System.out.println(list.get(i));
        }
    }
}
